package com.zheng.定义数组工具类;

import java.util.Arrays;
import java.util.Scanner;

public class MyArraysImpl extends MyArrays{
    @Override
    public void showArrayAll(int[] arr) {
        System.out.println(Arrays.toString(arr));
    }

    @Override
    public int getArrayIndex(int[] arr,int number) {
        return Arrays.binarySearch(arr,number);
    }

    @Override
    public int[] getArray(int[] arr) {
        int[] newarr=new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            newarr[i]=arr[arr.length-1-i];
        }
        return newarr;
    }

    @Override
    public void ArrayIndexDelete(int[] arr, int index) {
        for (int i = index; i < arr.length; i++) {
            if (i==arr.length-1){
                arr[i]=0;
            }else {
                arr[i]=arr[i+1];
            }
        }
    }

    @Override
    public void ArrayIndexAdd(int[] arr, int index) {
        System.out.println("请输入你要添加的元素");
        int count=new Scanner(System.in).nextInt();
        arr[index]=count;

    }

    @Override
    public boolean ArrayIfFull(int[] arr) {
        int index=0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i]!=0){
                index++;
            }
        }
        return index==arr.length;
    }
}
